package cn.bdqn.mh.controller.api;

import cn.bdqn.mh.pojo.Ad;
import cn.bdqn.mh.response.Result;
import cn.bdqn.mh.response.ResultCode;
import cn.bdqn.mh.service.AdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/house")
@Configuration(value = "website")
@Api(value = "广告信息接口文档")
@Slf4j
public class AdController {

    @Autowired
    private AdService adService;

    @GetMapping("/ad")
    @ApiOperation(value = "查询租家优选")
    public Object ad(){
        List<Ad> list=adService.getAd();
        Result result=null;
        if(list==null || list.size()==0){
            result = new Result(ResultCode.NO_DATAFOUND);
        }else {
            result = new Result(ResultCode.SUCCESS,list);
        }
        return result;
    }
}
